<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp"%>
<%
   //创建部门 DEPT_REGISTER =9
    hospital = 1113;
    //先删除部门
    QBuilder.db("basedb").execHQL("delete from Dept where hospital = " + hospital + "  and type = " + DEPT_REGISTER);
    //然后调用接口
    String json = HttpUtil.post(  "http://192.168.1.250:8080/dept/list.jsp");
    Map map = JSONUtil.mapFromJson(json);
    List<Map> list = (List<Map> )map.get("data");
    List deptList = new ArrayList();
   if(list != null && list.size() > 0){
       int order = 0;
       for(Map map1 : list){
            String name = (String)map1.get("name");
           if(name.indexOf("急诊") != -1){
               continue;
           }
           String yydm = (String)map1.get("yydm");
            Dept dept = new Dept();
            dept.setDeptName(name);
            dept.setStatus(1);
            dept.setHospital(hospital);
           dept.setDeptOrder(order);
           dept.setHospitalOrder(order);
           dept.setType(DEPT_REGISTER);
           dept.setBranch(yydm);
           dept.setBranchName("01".equals(yydm) ? "安镇" : "广瑞路");
           dept.setDeptId(map1.get("id")+"");
           order++;
           deptList.add(dept);
       }

       DBTools.db("basedb").addItem(deptList);
       out.println("执行完毕");
   }
%>
